import { createStore } from 'vuex'
export default createStore({
    state:{
        isCollapse:true,
        menu: [],
    },
    mutations:{
        updateIsCollapse(state,payload){
            state.isCollapse=!state.isCollapse
        },
        setMenu(state, val) {
            state.menu = val
            localStorage.setItem('menu', JSON.stringify(val))
          },

// 解决菜单持久化的问题
// 
        addMenu(state){
            if(!localStorage.getItem('menu')){
                return
            }
            const menu =JSON.parse(localStorage.getItem('menu'))
            state.menu=menu
        }
    }
})